package com.dw.etl.core.service;

import com.dw.etl.common.util.UUIDUtil;
import  com.dw.etl.common.vo.PaginationVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import com.dw.etl.core.api.MdMedPutfdService;
import com.dw.etl.core.mapper.MdMedPutfdMapper;
import com.dw.etl.core.bean.model.MdMedPutfd;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * mdMedPutfd服务实现类
 * Created by hozeData on 2021/06/17.
 */
@Service
@Transactional
public class MdMedPutfdServiceImpl implements MdMedPutfdService{

    private static final Logger LOGGER = LoggerFactory.getLogger(MdMedPutfdServiceImpl.class);

    @Autowired
    private MdMedPutfdMapper mdMedPutfdMapper;

    @Override
    public int insert(MdMedPutfd mdMedPutfd) {
        if(StringUtils.isEmpty(mdMedPutfd.getPk())){
            String uuid32 = UUIDUtil.getUUID32();
            mdMedPutfd.setPk(uuid32);
        }
        return mdMedPutfdMapper.insert(mdMedPutfd);
    }

    @Override
    public int insertSelective(MdMedPutfd mdMedPutfd)  {
        if(StringUtils.isEmpty(mdMedPutfd.getPk())){
            String uuid32 = UUIDUtil.getUUID32();
            mdMedPutfd.setPk(uuid32);
        }
        return mdMedPutfdMapper.insertSelective(mdMedPutfd);
    }

    @Override
    public int deleteById(String pk)  {
        return mdMedPutfdMapper.deleteByPrimaryKey(pk);
    }

    @Override
    public int updateByIdSelective(MdMedPutfd mdMedPutfd)  {

        return mdMedPutfdMapper.updateByPrimaryKeySelective(mdMedPutfd);
    }

    @Override
    public int updateById(MdMedPutfd mdMedPutfd)  {
        return mdMedPutfdMapper.updateByPrimaryKey(mdMedPutfd);
    }

    @Override
    public MdMedPutfd getById(String pk)  {
        return mdMedPutfdMapper.selectByPrimaryKey(pk);
    }

    @Override
    public List<MdMedPutfd> findByModel(MdMedPutfd mdMedPutfd)  {
        return mdMedPutfdMapper.findByModel(mdMedPutfd);
    }

    @Override
    public PaginationVO<MdMedPutfd> findPageByModel(MdMedPutfd mdMedPutfd, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum == null? 1 : pageNum, pageSize == null? 10 : pageSize);
        List<MdMedPutfd> quesList = mdMedPutfdMapper.findByModel(mdMedPutfd);
        PageInfo<MdMedPutfd> pageInfo = new PageInfo<>(quesList);
        PaginationVO<MdMedPutfd> paginationVo = new PaginationVO(pageInfo.getTotal(), pageInfo.getList());
        return paginationVo;
    }





}
